﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using personalplaner.common.mvvm;
using System.Windows;
using personalplaner.business;
using personalplaner.common.mvvm.commands;
using System.Windows.Input;

namespace personalplaner.plugins.plananalysis.viewmodels
{
	public class PrintViewModel : BaseViewModel
	{
		public PrintViewModel(DependencyObject parent)
            : base(parent)
        {
        }

		#region Commands

		ICommand _okcommand;
		public ICommand OkCommand
		{
			get
			{
				if (_okcommand == null)
					_okcommand = new RelayCommand(OnOkCommand);
				return _okcommand;
			}
		}

		private void OnOkCommand(object parameter)
		{
			var wnd = Parent as Window;
			if (wnd != null)
			{
				wnd.DialogResult = true;
				wnd.Close();
				return;
			}

			var mw = GetService<IMainWindowDisplayContainer>();
			mw.MoveToPreviousView();
		}

		ICommand _cancelcommand;
		public ICommand CancelCommand
		{
			get
			{
				if (_cancelcommand == null)
					_cancelcommand = new RelayCommand(OnCancelCommand);
				return _cancelcommand;
			}
		}

		private void OnCancelCommand(object parameter)
		{
			var wnd = Parent as Window;
			if (wnd != null)
			{
				wnd.DialogResult = false;
				wnd.Close();
				return;
			}

			var mw = GetService<IMainWindowDisplayContainer>();
			mw.MoveToPreviousView();
		}

		#endregion

		#region Properties

		IEnumerable<UIElement> _pages;
		public IEnumerable<UIElement> Pages
		{
			get { return _pages; }
			set
			{
				_pages = value;
				RaisePropertyChanged("Pages");
			}
		}

		#endregion
	}
}
